//
//  XZGMap.m
//  mapTest
//
//  Created by xiangzhigang on 16/5/25.
//  Copyright © 2016年 xiangzhi gang. All rights reserved.
//
#define MAS_SHORTHAND
#define MAS_SHORTHAND_GLOBALS
#import "XZGMap.h"
#import <MapKit/MapKit.h>
#import "MapAnnotation.h"
#import <Masonry/Masonry.h>
#import "XZGMapTableViewController.h"

@interface XZGMap ()<MKMapViewDelegate>


@end

@implementation XZGMap

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.mapView];
    
    
    [self.mapView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.top.equalTo(self.view);
        make.width.equalTo(self.view);
        make.height.equalTo(self.view);

    }];
    

    
    self.mapView.backgroundColor = [UIColor greenColor];

    self.mapView.delegate = self;

    MapAnnotation *annotation = [[MapAnnotation alloc] init];
    
    
    annotation.coordinate = self.coordinate2;
//    NSLog(@"%lf,%lf",self.coordinate2.latitude,self.coordinate2.longitude);

    annotation.title = @"医院";
    [self.mapView addAnnotation:annotation];
    [self.mapView setRegion:MKCoordinateRegionMakeWithDistance(self.coordinate2, 2000, 2000)];
}



- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    MKPinAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapSample"];
    
    annotationView.canShowCallout = YES;
    
    return annotationView;
}


- (MKMapView *)mapView {
    if (_mapView == nil) {
        _mapView = [[MKMapView alloc] init];
    }
    return _mapView;
}

@end
